<template>
  <div class="micro-tab-nav-box">
    <!--预览控制区-->
    <div class="design-preview-controller">
      <!--文本-->
      <div class="nav-list"
           v-if="formData.set.type === 3">
        <div :class="['nav-item-item text_overFlow_1 nav-item-image-li', formData.size==4? 'column-four': 'column-five']"
             v-for="(item,index) in showNav"
             :key="index">
          <span :style="{color:formData.set.font_color}">{{item.title || `demo${index+1}`}}</span>
        </div>
      </div>
      <!--模式 图文-->
      <div v-else
           class="nav-item-image">
        <div :class="['nav-item-image-li', formData.size==4? 'column-four': 'column-five']"
             v-for="(item,index) in showNav"
             :key="index">
          <img :class="[formData.set.type === 1 ? 'pure-img' : '']"
               :src="item.img || defPic">
          <!--图文模式-->
          <p v-if="formData.set.type !==1"
             class="text_overFlow_1"
             :style="{color:formData.set.font_color}">
            {{item.title || `demo${index+1}`}}</p>
        </div>
        <!-- 补齐flex布局样式 -->
        <slot v-if="showNav.length % formData.size !=0">
          <div :class="['nav-item-image-li', formData.size==4? 'column-four': 'column-five']"
               style="visibility:hidden;"
               v-for="(item,index) in formData.size - (showNav.length % formData.size)"
               :key="index + 100">
            <img :src="defPic">
            <!--图文模式-->
            <p v-if="formData.set.type !==1"
               class="text_overFlow_1">
              {{item.title || `demo${index+1}`}}</p>
          </div>
        </slot>
      </div>
      <!-- <div class="nav-content">
        显示内容，客户端才能展示
      </div> -->
    </div>
    <!--编辑工作区-->
    <div class="design-editor-item design-hide-class"
         v-if="isShowEdit">
      <div class="design-config-editor">
        <div class="design-editor-component-title">{{$t('shopFeature.tabNav.navBar')}}</div>
        <div class="tab-nav-set">
          <!-- 配置-->
          <div class="tab-set-box">
            <el-form ref="formData">
              <el-form-item>
                <el-radio-group v-model="formData.set.type">
                  <el-radio-button v-for="(typeItem, index) in setTypeList"
                                   :key="index"
                                   :label="typeItem.type">{{typeItem.title}}</el-radio-button>
                </el-radio-group>
              </el-form-item>
              <el-form-item :label="$i18n.t('shopFeature.tabNav.countInLine')">
                <el-radio-group v-model="formData.size">
                  <el-radio v-for="(typeItem, index) in setCountsList"
                            :key="index"
                            :label="typeItem.value">{{typeItem.label}}</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-form>
          </div>
          <!-- 各个导航分类 -->
          <div class="tab-nav-set-item" :style="{borderColor:errIndex===index ? '#f56c6c': '#eee'}"
               v-for="(item,index) in formData.nav"
               :key="index">
            <div class="set-box">
              <!--图片-->
              <div class="set-image"
                   v-if="formData.set.type !==3"
                   @click="choosePic(index)"
                   :style="{backgroundImage:'url('+item.img+')'}">
                <span v-if="!item.img">+</span>
                <div class="set-image-add">{{item.img? $t('shopFeature.tabNav.changePic') : $t('shopFeature.tabNav.addPic')}}</div>
              </div>
              <!-- 标题信息-->
              <div class="set-info">
                <div class="set-item-title"
                     v-if="formData.set.type !==1">
                  {{$t('shopFeature.tabNav.tit')}}
                  <p>
                    <el-input maxlength="25"
                              size="mini"
                              :placeholder="$i18n.t('shopFeature.tabNav.tit')"
                              v-model="item.title">
                    </el-input>
                  </p>
                </div>
                <div class="set-item-title choose-micro show">
                  <span>{{$t('shopFeature.tabNav.routeLink')}}</span>
                  <el-dropdown trigger="click"
                             size="small"
                             @command="command"
                            class="ad-image-link-dropdown">
                  <div class="cursor color">
                    <span class="type-name" v-if="!item.linkTitle">{{$t('shopFeature.tabNav.choose')}}</span>
                    <span class="type-name" v-else>
                      {{[linkList[item.linkType-2].linkTitle] | pathFilter}}
                      <i class="el-icon-close" @click.stop="resetLink(index)" />
                    </span>
                  </div>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item v-for="(linkItem,linkIndex) in linkList"
                                      :key="linkIndex"
                                      :command="({linkItem,currentEditIndex:index})">
                      <span style="font-size: 12px;">{{ linkItem.linkTitle }}</span>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
                <p class="goods-name" v-if="item.linkType===1 || item.linkType===5" @click="reChooseLink(item, index)">{{ item.linkType===5 && item.microTitle ? item.microTitle : item.linkTitle ? item.linkTitle : $t('shopFeature.tabNav.choose') }} </p>
                </div>
                <div class="btn-type-input custom-path" @click="reChooseLink(item, index)" v-if="item.linkType===4">{{item.link}}</div>               
              </div>
            </div>
            <span class="set-close"
                  @click="formData.nav.splice(index,1)">X</span>
          </div>
          <div class="tab-nav-add"
               @click="addNav">{{$t('shopFeature.tabNav.addNav')}}</div>
        </div>
      </div>
    </div>
    <!--选择微页面-->
    <el-dialog custom-class="up-dialog"
               :close-on-click-modal="false"
               top="5vh"
               :title="$i18n.t('shopFeature.tabNav.microPage')"
               :visible.sync="dialogChoosePages"
               width="42%">
      <div class="choose-goods-compent">
        <choose-feature :isGetChooseData="isGetChooseFeature"
                        @chooseChooseFeaturesFun="chooseChooseFeaturesFun"></choose-feature>
        <div slot="footer"
             style="text-align: right;margin-top: 20px;">
          <el-button size="mini"
                     type="primary"
                     @click="isGetChooseFeature=!isGetChooseFeature">{{$t('shopFeature.tabNav.confirm')}}</el-button>
          <el-button size="mini"
                     @click="dialogChoosePages = false">{{$t('shopFeature.tabNav.cancel')}}</el-button>
        </div>
      </div>
    </el-dialog>
    <!-- 弹窗, 新增图片 -->
    <elx-imgbox ref="elxImgbox"
                @refreshPic="refreshPic"
                :maxSize="10"
                :imgSizeLimit="false"></elx-imgbox>
    <!-- 商品选择弹窗  -->
    <prods-select v-if="dialogChooseGoods"
                  ref="ProdsSelect"
                  :isSingle="true"
                  @refreshSelectProds="chooseGoodsFun"></prods-select>
    <!-- 弹窗: 输入自定义路径 -->
    <el-dialog custom-class="up-dialog" :title="$i18n.t('shopFeature.tabNav.customPath')" width="40%" top="30vh" :visible.sync="showPathInputDialog">
      <div class="custom-path-con">
        <span>{{$t('shopFeature.tabNav.routeLink')}}</span>
        <el-input style="margin-rigth: 10px;" :placeholder="$i18n.t('shopFeature.tabNav.pleaseFillThePath')" size="small" v-model="customPath">

        </el-input>
      </div>
      <div slot="footer" style="text-align: right;">
          <el-button size="mini"
                     type="primary"
                     @click="customPathComfirm">{{$t('shopFeature.tabNav.confirm')}}</el-button>
          <el-button size="mini"
                     @click="customPathCancel">{{$t('shopFeature.tabNav.cancel')}}</el-button>
        </div>
    </el-dialog>
  </div>
</template>
<script>
import index from './index.js'

export default index
</script>
